import React from "react";
import "./index.less";
import { bindActionCreators } from "redux";
import { updateLogin } from "./redux";
import { connect } from "react-redux";
import View from "./view";

class Login extends React.Component {
  constructor() {
    super();
    this.login = this.login.bind(this);
  }

  login(data) {
    // 修改登陆状态
    this.props.updateLogin(true);
    this.props.history.push("/my");
  }

  render() {
    return <View login={this.login}></View>;
  }
}

// export default Login;

function mapStateToProps(state) {
  return {
    isLogin: state.login.isLogin
  };
}

function mapDisapatchToProps(dispatch) {
  return {
    updateLogin: bindActionCreators(updateLogin, dispatch)
  };
}

export default connect(mapStateToProps, mapDisapatchToProps)(Login);
